<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<!--#include file="lib/error_write.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script type="text/javascript">
	$(function() {
		$("input:checked").next().next().removeAttr("disabled")
		$("input[name='post']").click(function(){
			if($(this).attr("checked")){
				$(this).next().next().removeAttr("disabled")
			}else{
				$(this).next().next().attr("disabled","disabled")
			}
		});
	});
</script>	
</head>
<%
call CheckRights(0,15)
id=saferequest("id",1)
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM yh WHERE id = "&id
rs.Open sql,conn,1,1

if request.form("mm_edit")<>"" then
	user=trim(SafeRequest("user",0))
	name=trim(SafeRequest("name",0))
	password1=trim(SafeRequest("password1",0))
	password2=trim(SafeRequest("password2",0))
	active=request.form("active")
	if active="" then active=false
	post=request.form("post")
	if user="" then error_write "1","没有填写[用户名]"
	if name="" then error_write "2","没有填写[姓名]"
	if post="" then error_write "3","没有选择[岗位]"
	if password1<>password2 Then error_write "4","密码不匹配"
	post=""
	flag=""
	for i=1 to request.form("post").count
		post=post&request.form("post")(i)&","
		flag=flag&request.form("flag")(i)&","
	next
	post=left(post,len(post)-1)
	flag=left(flag,len(flag)-1)
	
	Set rs1 = Server.CreateObject("ADODB.Recordset")
	sql = "SELECT *  FROM yh where id<>"&id&" and [user]='"&user&"'"
	rs1.Open sql,conn,1,1
	if not rs1.eof then error_write "4","[用户名]重复"
	rs1.close
	set rs1=nothing
	
	
	set cmd=Server.CreateObject("ADODB.Command")
	cmd.ActiveConnection = conn
	sql="update yh set [user]='"&user&"',[pass]='"&password1&"',flag='"&flag&"',post='"&post&"',[name]='"&name&"',[active]="&active&" where id="&id
	'response.Write(sql)
	cmd.CommandText = sql
	cmd.Execute
	view_url="manage_user.asp"
	response.Redirect(view_url)
end if




%>

<body>
<div class="navbar">
	<a href="manage_user.asp">用户信息管理</a>&gt;&gt;<a href="edit_user.asp?id=<%=id%>">编辑用户</a>&gt;&gt;
</div>

<form name="form1" method="post" action="edit_user.asp?id=<%=id%>">
	<fieldset>
		<legend>资料</legend>
		<div>
			<label>ID</label>
			<label><%=rs("id")%></label>
		</div>
		<div>
			<label>用户名*</label>
			<input name="user" type="text" id="user" size="10" value="<%=rs("user")%>" />
		</div>
		<div>
			<label>密码*</label>
			<input name="password1" type="password" id="password1" size="15" value="<%=rs("pass")%>" />
		</div>
		<div>
			<label>确认密码*</label>
			<input name="password2" type="password" id="password2" size="15" value="<%=rs("pass")%>" />
		</div>
		<div>
			<label>姓名*</label>
			<input name="name" type="text" id="name" size="8" value="<%=rs("name")%>" />
		</div>
	</fieldset>
	<fieldset>
		<legend>岗位和权限*</legend>
		<div>
			<input name="post" type="checkbox" value="0" <%if cpost(rs("post"),0) then response.write("checked='checked'")%> /><label>用户权限</label>
			<select name="flag" disabled="disabled">
				<option value="1" <%if cpost(rs("post"),0) and vflag(rs("flag"),lpost(rs("post"),0))=1 then response.write("selected")%>>查询</option>
				<option value="2" <%if cpost(rs("post"),0) and vflag(rs("flag"),lpost(rs("post"),0))=2 then response.write("selected")%>>查询、查看</option>
				<option value="3" <%if cpost(rs("post"),0) and vflag(rs("flag"),lpost(rs("post"),0))=3 then response.write("selected")%>>查询、查看、添加</option>
				<option value="4" <%if cpost(rs("post"),0) and vflag(rs("flag"),lpost(rs("post"),0))=4 then response.write("selected")%>>查询、查看、添加、编辑</option>
				<option value="5" <%if cpost(rs("post"),0) and vflag(rs("flag"),lpost(rs("post"),0))=5 then response.write("selected")%>>查询、查看、添加、编辑、删除</option>
				<option value="15" <%if cpost(rs("post"),0) and vflag(rs("flag"),lpost(rs("post"),0))=15 then response.write("selected")%>>管理员</option>
			</select>
		</div>
		<div>
			<input name="post" type="checkbox" value="1" <%if cpost(rs("post"),1) then response.write("checked='checked'")%> /><label>船务</label>
			<select name="flag" disabled="disabled">
				<option value="1" <%if cpost(rs("post"),1) and vflag(rs("flag"),lpost(rs("post"),1))=1 then response.write("selected")%>>查询</option>
				<option value="2" <%if cpost(rs("post"),1) and vflag(rs("flag"),lpost(rs("post"),1))=2 then response.write("selected")%>>查询、查看</option>
				<option value="3" <%if cpost(rs("post"),1) and vflag(rs("flag"),lpost(rs("post"),1))=3 then response.write("selected")%>>查询、查看、添加</option>
				<option value="4" <%if cpost(rs("post"),1) and vflag(rs("flag"),lpost(rs("post"),1))=4 then response.write("selected")%>>查询、查看、添加、编辑</option>
				<option value="5" <%if cpost(rs("post"),1) and vflag(rs("flag"),lpost(rs("post"),1))=5 then response.write("selected")%>>查询、查看、添加、编辑、删除</option>
				<option value="15" <%if cpost(rs("post"),1) and vflag(rs("flag"),lpost(rs("post"),1))=15 then response.write("selected")%>>管理员</option>
			</select>
		</div>
		<div>
			<input name="post" type="checkbox" value="2" <%if cpost(rs("post"),2) then response.write("checked='checked'")%> /><label>车队</label>
			<select name="flag" disabled="disabled">
				<option value="1" <%if cpost(rs("post"),2) and vflag(rs("flag"),lpost(rs("post"),2))=1 then response.write("selected")%>>查询</option>
				<option value="2" <%if cpost(rs("post"),2) and vflag(rs("flag"),lpost(rs("post"),2))=2 then response.write("selected")%>>查询、查看</option>
				<option value="3" <%if cpost(rs("post"),2) and vflag(rs("flag"),lpost(rs("post"),2))=3 then response.write("selected")%>>查询、查看、添加</option>
				<option value="4" <%if cpost(rs("post"),2) and vflag(rs("flag"),lpost(rs("post"),2))=4 then response.write("selected")%>>查询、查看、添加、编辑</option>
				<option value="5" <%if cpost(rs("post"),2) and vflag(rs("flag"),lpost(rs("post"),2))=5 then response.write("selected")%>>查询、查看、添加、编辑、删除</option>
				<option value="15" <%if cpost(rs("post"),2) and vflag(rs("flag"),lpost(rs("post"),2))=15 then response.write("selected")%>>管理员</option>
			</select>
		</div>
		<div>
			<input name="post" type="checkbox" value="3" <%if cpost(rs("post"),3) then response.write("checked='checked'")%> /><label>商务</label>
			<select name="flag" disabled="disabled">
				<option value="1" <%if cpost(rs("post"),3) and vflag(rs("flag"),lpost(rs("post"),3))=1 then response.write("selected")%>>查询</option>
				<option value="2" <%if cpost(rs("post"),3) and vflag(rs("flag"),lpost(rs("post"),3))=2 then response.write("selected")%>>查询、查看</option>
				<option value="3" <%if cpost(rs("post"),3) and vflag(rs("flag"),lpost(rs("post"),3))=3 then response.write("selected")%>>查询、查看、添加</option>
				<option value="4" <%if cpost(rs("post"),3) and vflag(rs("flag"),lpost(rs("post"),3))=4 then response.write("selected")%>>查询、查看、添加、编辑</option>
				<option value="5" <%if cpost(rs("post"),3) and vflag(rs("flag"),lpost(rs("post"),3))=5 then response.write("selected")%>>查询、查看、添加、编辑、删除</option>
				<option value="15" <%if cpost(rs("post"),3) and vflag(rs("flag"),lpost(rs("post"),3))=15 then response.write("selected")%>>管理员</option>
			</select>
		</div>
		<div>
			<input name="post" type="checkbox" value="4" <%if cpost(rs("post"),4) then response.write("checked='checked'")%> /><label>财务</label>
			<select name="flag" disabled="disabled">
				<option value="1" <%if cpost(rs("post"),4) and vflag(rs("flag"),lpost(rs("post"),4))=1 then response.write("selected")%>>查询</option>
				<option value="2" <%if cpost(rs("post"),4) and vflag(rs("flag"),lpost(rs("post"),4))=2 then response.write("selected")%>>查询、查看</option>
				<option value="3" <%if cpost(rs("post"),4) and vflag(rs("flag"),lpost(rs("post"),4))=3 then response.write("selected")%>>查询、查看、添加</option>
				<option value="4" <%if cpost(rs("post"),4) and vflag(rs("flag"),lpost(rs("post"),4))=4 then response.write("selected")%>>查询、查看、添加、编辑</option>
				<option value="5" <%if cpost(rs("post"),4) and vflag(rs("flag"),lpost(rs("post"),4))=5 then response.write("selected")%>>查询、查看、添加、编辑、删除</option>
				<option value="15" <%if cpost(rs("post"),4) and vflag(rs("flag"),lpost(rs("post"),4))=15 then response.write("selected")%>>管理员</option>
			</select>
		</div>
	</fieldset>
	<fieldset>
		<legend>激活</legend>
		<div>
			<input name="active" type="checkbox" value="true" <%if rs("active") then response.write("checked='checked'")%> /><label>激活用户</label>
		</div>
	</fieldset>
	<input type="submit" name="Submit" value="提交">&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="reset" name="Reset" value="重置">
	<input type="hidden" name="mm_edit" value="true">
</form>
<div>
	<ul>注意事项：
		<li>每个岗位都有自己的权限，需要分别设置岗位权限</li>
		<li>如果用户离职，只需修改激活状态即可</li>
	</ul>
</div>
</body>
</html>
<%
rs.Close()
Set rs = Nothing
conn.close
set conn=nothing
%>
